<html>
	<head>
		<title></title>
	</head>
	<body>
		
	</body>
	<script>
		/*方法一*/
	 var num = [1,7,4,2,5,10,3,11];
	 num.sort(function(a,b){
	 	return a-b
	 })
	 /*方法二 冒泡排序*/
	 
	 
	 var num1 = [1,3,2,6,10,7,9,8,12];
	 for (var i = 0; i<num1.length;i++) {
	 	for (var j = i+1;j<num1.length;j++) {
	 		if(num1[i]>num1[j]){
	 			var temp = num1[i];
	 			num1[i] = num1[j];
	 			num1[j] = temp;
	 		}
	 	}
	 }
	/*方法三 选择排序*/
	
	num2 = [1,3,2,6,10,7,9,8,12];
	var minN;
	for (var i =0;i<num2.length;i++) {
		var minTemp = i;
		for (var j=i+1;j<num2.length;j++) {
			if(num2[j]<num2[minTemp]){
				
				minTemp = j;
				
			}
		}
		minN = num2[i];
		num2[i] = num2[minTemp];
		num2[minTemp] = minN;
		
	}
        
   		/*快排*/
        function Sort(arr){
         	if(arr.length<=1){return arr;}
           	 var midIndex=Math.floor(arr.length/2);
         	 var mid=arr.splice(midIndex,1)[0];
         	 console.log(mid)
             var left=[];
             var right=[];
             for(var i=0;i<arr.length;i++){
                if(arr[i]<=mid){
                    left.push(arr[i]);
                }
                else{
                    right.push(arr[i]);
                }
            }
             return Sort(left).concat([mid],Sort(right));
         }
         
  
        
    </script>
</html>
